package es_deusto_engineering_IS_HanoiTower;

import java.util.Scanner;

import es.deusto.ingenieria.is.search.algorithms.Node;
import es.deusto.ingenieria.is.search.algorithms.blind.BreadthFS;
import es.deusto.ingenieria.is.search.algorithms.blind.BreadthFSwithLog;
import es.deusto.ingenieria.is.search.algorithms.blind.DepthFS;
public class MainProgram {

	/**Test of the methods we have just created.
	 * @param args
	 */
	public static void main(String[] args) {
	 
	
	  //We ask for the different parameters from keyboard.
      Scanner percepts = new Scanner(System.in);
      System.out.println("Enter the number of pegs: ");
      int numPegs = percepts.nextInt();
      System.out.println("Enter the origin peg:  " +"(>0 and < " + (numPegs+1)+")");
      int origin = percepts.nextInt();
      System.out.println("Enter the destination peg: " + "(>0 and < " + (numPegs+1)+")");
      int dest = percepts.nextInt();
      System.out.println("Enter the numer of disks: ");
      int disks = percepts.nextInt();
      
      //Create the environment with the parameters defined before
      Environment envi = new Environment(numPegs,origin,dest,disks);
      
      //Check if the environment has the correct number of pegs and that the distribution of disks is correctly arranged
      System.out.println(envi.toString()+"\n");
      
      //In order to know if the origin and destination are correct
      System.out.println("Information of the origin peg:" + envi.getOrigin().toString()+"\n");
      System.out.println("Information of the destination peg:" + envi.getDestination().toString()+"\n");
      
      //We create a HanoiTowerProblem object and we enter as parameter the number of disks that the problem must have
      HanoiTowerProblem p = new HanoiTowerProblem(disks, numPegs);
     
      //We add to the problem the initial state, (defined previously)
      p.addInitialState(envi);
      
      //We create operators within the HanoiTowerProblem, this methods makes as many instances as we want of Action 
      //(Operator subclass)
      p.createOperators();
      
      //Breadh First Search Algorithm --> taking into account that it is applied singleton design pattern.
      BreadthFS breadth = BreadthFS.getInstance();
      p.solve(breadth);
      
      //Depth First Search Algorithm
      DepthFS depth = DepthFS.getInstance();
      p.solve(depth);
       
	}
}
